package com.example.takephotovideo.showphotovideo;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.example.takephotovideo.R;
import com.example.takephotovideo.base.BaseActivity;
import com.example.takephotovideo.utils.title_utils.StatusBarUtil;

import cn.jzvd.JzvdStd;

/**
 * @功能: 展示视频的详情界面
 * @Creat 2020/3/18 15:43
 * @User Lmy
 * @Compony JinAnChang
 */
public class VideoShowActivity extends BaseActivity implements View.OnClickListener {
    private static String video_url;
    private JzvdStd videoplayer;
    private ImageView ivBack;
    public static void show(Context context, String url) {
        context.startActivity(new Intent(context, VideoShowActivity.class));
        VideoShowActivity.video_url = url;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_show);
        StatusBarUtil.setRootViewFitsSystemWindows(this, false);
        StatusBarUtil.setTranslucentStatus(this);
        initView();
    }
    private void initView() {
        videoplayer = findViewById(R.id.videoplayer);
        ivBack = findViewById(R.id.iv_back);
        ivBack.setOnClickListener(this);
        videoplayer.setUp(video_url, "",
                JzvdStd.SCREEN_NORMAL);
        videoplayer.thumbImageView.setScaleType(ImageView.ScaleType.FIT_XY);
        videoplayer.setVideoImageDisplayType(1);
        Glide.with(videoplayer.getContext()).load(video_url).
                into(videoplayer.thumbImageView);
    }
    @Override
    public void onBackPressed() {
        if (videoplayer.backPress()) {
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        videoplayer.releaseAllVideos();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }
}
